package com.ft.oa.web.development;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ft.oa.domain.dev.DevAllocateAccept;
import com.ft.oa.domain.development.DevAllocate;
import com.ft.oa.domain.development.DevNeedIssue;
import com.ft.oa.domain.dto.ApiResult;
import com.ft.oa.mapper.industrysMapper.DevNeedAnalyseMapper;
import com.ft.oa.service.development.DevExecService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 研发管理-研发执行管理接口
 */
@RestController
@RequestMapping("/dev/exec")
public class DevExecController {

    @Resource
    private DevExecService devExecService;

    /**
     * 研发项目未分配分页
     */
    @PostMapping("/page")
    public ApiResult page(@RequestBody DevNeedIssue condition){

        Page<DevNeedIssue> result = devExecService.page(condition);
        return ApiResult.successWithData(result);
    }

    /**
     * 研发分配审批人列表
     */
    @GetMapping("/approverList")
    public ApiResult approverList(){

        ApiResult result = devExecService.approverList();

        return result;
    }

    /**
     * 研发分配抄送人列表
     */
    @GetMapping("/copyerList")
    public ApiResult copyerList(){

        ApiResult result = devExecService.copyerList();

        return result;
    }

    /**
     * 研发项目分配
     */
    @PostMapping("/allocate")
    public ApiResult allocate(@RequestBody DevAllocate allocate){

        ApiResult result = devExecService.allocate(allocate);

        return result;
    }

    /**
     * 研发项目已分配分页
     */
    @PostMapping("/allocated/page")
    public ApiResult allocatedPage(@RequestBody DevAllocate allocate){

        Page<DevAllocate> result = devExecService.allocatedPage(allocate);
        return ApiResult.successWithData(result);
    }
    /**
     * 研发项目分配未分配详情
     */
    @PostMapping("/devNeedIssueDetail")
    public ApiResult devNeedIssueDetail(@RequestBody DevNeedIssue devNeedIssue){

        Map result = devExecService.devNeedIssueDetail(devNeedIssue.getId());

        return ApiResult.successWithData(result);
    }
    /**
     * 研发项目分配已分配详情
     */
    @PostMapping("/devNeedAllocateDetail")
    public ApiResult devNeedAllocateDetail(@RequestBody DevAllocate devAllocate){

        Map result = devExecService.devNeedAllocateDetail(devAllocate.getId());

        return ApiResult.successWithData(result);
    }

    @PostMapping("/devNeedAllocateAccept")
    public ApiResult devNeedAllocateAccept(@RequestBody DevAllocateAccept devAllocateAccept){
        ApiResult result =  devExecService.devNeedAllocateAccept(devAllocateAccept);

        return result;
    }
}
